home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / psgml / psgml.el.z / psgml.el
Encoding:
Text File  |  1998-05-21  |  57.4 KB  |  1,531 lines

  1. ;;; psgml.el --- SGML-editing mode with parsing support
  2. ;; $Id: psgml.el,v 2.20 1996/11/20 18:39:14 lenst Exp $
  3.  
  4. ;; Copyright (C) 1993, 1994, 1995, 1996 Lennart Staflin
  5. ;; Copyright (C) 1992 Free Software Foundation, Inc.
  6.  
  7. ;; Author: Lennart Staflin <lenst@lysator.liu.se>
  8. ;;     James Clark <jjc@clark.com>
  9. ;; Maintainer: Lennart Staflin <lenst@lysator.liu.se>
  10. ;; Keywords: languages
  11.  
  12. ;; 
  13. ;; This program is free software; you can redistribute it and/or
  14. ;; modify it under the terms of the GNU General Public License
  15. ;; as published by the Free Software Foundation; either version 2
  16. ;; of the License, or (at your option) any later version.
  17. ;; 
  18. ;; This program is distributed in the hope that it will be useful,
  19. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. ;; GNU General Public License for more details.
  22. ;; 
  23. ;; You should have received a copy of the GNU General Public License
  24. ;; along with this program; if not, write to the Free Software
  25. ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26.  
  27.  
  28. ;;; Commentary:
  29.  
  30. ;; Major mode for editing the SGML document-markup language.
  31.  
  32. ;; Send bugs to lenst@lysator.liu.se
  33.  
  34. ;; WHAT IT CAN DO
  35.  
  36. ;; - Identify structural errors (but it is not a validator)
  37. ;; - Menus for inserting tags with only the contextually valid tags
  38. ;; - Edit attribute values in separate window with information about types 
  39. ;;   and defaults
  40. ;; - Hide attributes
  41. ;; - Fold elements
  42. ;; - Indent according to element nesting depth
  43. ;; - Show context
  44. ;; - Structure editing: move and kill by element
  45. ;; - Find next data context
  46.  
  47. ;; LIMITATIONS
  48.  
  49. ;; - only accepts the referece concrete syntax, though it does allow
  50. ;;   unlimited lengths on names
  51.  
  52.  
  53. ;;; Code:
  54.  
  55. (defconst psgml-version "1.0.1"
  56.   "Version of psgml package.")
  57.  
  58. (defconst psgml-maintainer-address "lenst@lysator.liu.se")
  59.  
  60. (require 'cl)
  61. (require 'easymenu)
  62.  
  63. (defvar sgml-debug nil)
  64.  
  65. (defmacro sgml-debug (&rest x) 
  66.   (list 'if 'sgml-debug (cons 'sgml-log-message x)))
  67.  
  68.  
  69. ;;;; Variables
  70.  
  71. (defvar sgml-mode-abbrev-table nil
  72.   "Abbrev table in use in sgml-mode.")
  73. (define-abbrev-table 'sgml-mode-abbrev-table ())
  74.  
  75. (defvar sgml-running-xemacs
  76.   (not (not (string-match "Lucid\\|XEmacs" emacs-version))))
  77.  
  78. ;;; User settable options:
  79.  
  80. (defgroup sgml nil
  81.   "Standard Generalized Markup Language"
  82.   :group 'languages)
  83.  
  84. (defgroup psgml nil
  85.   "SGML-editing mode with parsing support"
  86.   :prefix "sgml-"
  87.   :group 'sgml)
  88.  
  89. (defgroup psgml-insert nil
  90.   "Inserting features of psgml"
  91.   :prefix "sgml-"
  92.   :group 'psgml)
  93.  
  94. (defgroup psgml-dtd nil
  95.   "DTD, CATALOG and DOCTYPE customizations in psgml"
  96.   :prefix "sgml-"
  97.   :group 'psgml)
  98.  
  99.  
  100. (defcustom sgml-insert-missing-element-comment t
  101.   "*If true, and sgml-auto-insert-required-elements also true,
  102. `sgml-insert-element' will insert a comment if there is an element required
  103. but there is more than one to choose from."
  104.   :type 'boolean
  105.   :group 'psgml-insert)
  106.  
  107. (defcustom sgml-insert-end-tag-on-new-line nil
  108.   "*If true, `sgml-insert-element' will put the end-tag on a new line
  109. after the start-tag. Useful on slow terminals if you find the end-tag after
  110. the cursor irritating."
  111.   :type 'boolean
  112.   :group 'psgml-insert)
  113.  
  114. (defvar sgml-doctype nil
  115.   "*If set, this should be the name of a file that contains the doctype
  116. declaration to use.
  117. Setting this variable automatically makes it local to the current buffer.")
  118. (put 'sgml-doctype 'sgml-type 'string)
  119. (make-variable-buffer-local 'sgml-doctype)
  120.  
  121. (defcustom sgml-system-identifiers-are-preferred nil
  122.   "*If nil, PSGML will look up external entities by searching the catalogs
  123. in `sgml-local-catalogs' and `sgml-catalog-files' and only if the
  124. entity is not found in the catalogs will a given system identifer be
  125. used. If the variable is non-nil and a system identifer is given, the
  126. system identifier will be used for the entity. If no system identifier
  127. is given the catalogs will searched."
  128.   :type 'boolean
  129.   :group 'psgml-dtd)
  130.  
  131. (defcustom sgml-range-indicator-max-length 9
  132.   "*Maximum number of characters used from the first and last entry
  133. of a submenu to indicate the range of that menu."
  134.   :type 'integer
  135.   :group 'psgml)
  136.  
  137. (defcustom sgml-default-doctype-name nil
  138.   "*Document type name to use if no document type declaration is present."
  139.   :type '(choice string (const nil))
  140.   :group 'psgml-dtd)
  141.  
  142. (put 'sgml-default-doctype-name 'sgml-type 'string-or-nil)
  143.  
  144. (defcustom sgml-markup-faces '((start-tag     . bold)
  145.                 (end-tag     . bold)
  146.                 (comment     . italic)
  147.                 (pi     . bold)
  148.                 (sgml     . bold)
  149.                 (doctype     . bold)
  150.                 (entity     . bold-italic)
  151.                 (shortref   . bold))
  152.   "*List of markup to face mappings.
  153. Element are of the form (MARKUP-TYPE . FACE).
  154. Possible values for MARKUP-TYPE is:
  155. comment    - comment declaration
  156. doctype    - doctype declaration
  157. end-tag 
  158. ignored    - ignored marked section
  159. ms-end    - marked section start, if not ignored 
  160. ms-start- marked section end, if not ignored
  161. pi    - processing instruction
  162. sgml    - SGML declaration
  163. start-tag
  164. entity  - general entity reference
  165. shortref- short reference"
  166.   :type '(repeat (cons symbol face))
  167.   :group 'psgml)
  168.  
  169. (defvar sgml-buggy-subst-char-in-region 
  170.   (or (not (boundp 'emacs-minor-version))
  171.       (not (natnump emacs-minor-version))
  172.       (< emacs-minor-version 23))
  173.   "*If non-nil, work around a bug in subst-char-in-region.
  174. The bug sets the buffer modified.  If this is set, folding commands
  175. will be slower.")
  176.  
  177. (defcustom sgml-set-face nil
  178.   "*If non-nil, psgml will set the face of parsed markup."
  179.   :type 'boolean
  180.   :group 'psgml)
  181. (put 'sgml-set-face 'sgml-desc "Set face of parsed markup")
  182.  
  183. (defcustom sgml-live-element-indicator nil
  184.   "*If non-nil, indicate current element in mode line."
  185.   :type 'boolean
  186.   :group 'psgml)
  187.  
  188. (defcustom sgml-auto-activate-dtd nil
  189.   "*If non-nil, loading a sgml-file will automatically try to activate its DTD.
  190. Activation means either to parse the document type declaration or to
  191. load a previously saved parsed DTD.  The name of the activated DTD
  192. will be shown in the mode line."
  193.   :type 'boolean
  194.   :group 'psgml-dtd)
  195. (put 'sgml-auto-activate-dtd 'sgml-desc "Auto Activate DTD")
  196.  
  197. (defcustom sgml-offer-save t
  198.   "*If non-nil, ask about saving modified buffers before \\[sgml-validate] is run."
  199.   :type 'boolean
  200.   :group 'psgml)
  201.  
  202. (defvar sgml-parent-document nil
  203.   "* Used when the current file is part of a bigger document.
  204.  
  205. The variable describes how the current file's content fit into the element
  206. hierarchy. The variable should have the form
  207.  
  208.   (PARENT-FILE CONTEXT-ELEMENT* TOP-ELEMENT (HAS-SEEN-ELEMENT*)?)
  209.  
  210. PARENT-FILE    is a string, the name of the file contatining the
  211.         document entity.
  212. CONTEXT-ELEMENT is a string, that is the name of an element type.
  213.         It can occur 0 or more times and is used to set up
  214.         exceptions and short reference map. Good candidates
  215.         for these elements are the elements open when the
  216.         entity pointing to the current file is used. 
  217. TOP-ELEMENT    is a string that is the name of the element type
  218.         of the top level element in the current file. The file
  219.         should contain one instance of this element, unless
  220.         the last \(lisp) element of sgml-parent-document is a
  221.         list. If it is a list, the top level of the file
  222.         should follow the content model of top-element. 
  223. HAS-SEEN-ELEMENT is a string that is the name of an element type. This
  224.             element is satisfied in the content model of top-element.
  225.  
  226. Setting this variable automatically makes it local to the current buffer.")
  227. (make-variable-buffer-local 'sgml-parent-document)
  228. (put 'sgml-parent-document 'sgml-type 'list)
  229.  
  230. (defcustom sgml-tag-region-if-active t ;; wing change
  231.   "*If non-nil, the Tags menu will tag a region if the region is 
  232. considered active by Emacs.  If nil, region must be active and
  233. transient-mark-mode/zmacs-regions must be on for the region to be tagged."
  234.   :type 'boolean
  235.   :group 'psgml)
  236.  
  237. (defvar sgml-normalize-trims t
  238.   "*If non-nil, sgml-normalize will trim off white space from end of element
  239. when adding end tag.")
  240.  
  241. (defvar sgml-omittag t
  242.   "*Set to non-nil, if you use OMITTAG YES.
  243.  
  244. Setting this variable automatically makes it local to the current buffer.")
  245.  
  246. (make-variable-buffer-local 'sgml-omittag)
  247. (put 'sgml-omittag 'sgml-desc "OMITTAG")
  248.  
  249. (defvar sgml-shorttag t
  250.   "*Set to non-nil, if you use SHORTTAG YES.
  251.  
  252. Setting this variable automatically makes it local to the current buffer.")
  253.  
  254. (make-variable-buffer-local 'sgml-shorttag)
  255. (put 'sgml-shorttag 'sgml-desc "SHORTTAG")
  256.  
  257. (defvar sgml-minimize-attributes nil
  258.   "*Determines minimization of attributes inserted by edit-attributes.
  259. Actually two things are done
  260. 1. If non-nil, omit attribute name, if attribute value is from a token group.
  261. 2. If 'max, omit attributes with default value.
  262.  
  263. Setting this variable automatically makes it local to the current buffer.")
  264.  
  265. (make-variable-buffer-local 'sgml-minimize-attributes)
  266. (put 'sgml-minimize-attributes 'sgml-type
  267.      '(("No" . nil) ("Yes" . t) ("Max" . max)))
  268.  
  269. (defvar sgml-always-quote-attributes t
  270.   "*If non-nil, quote all attribute values inserted after finishing edit attributes.
  271. Setting this variable automatically makes it local to the current buffer.")
  272.  
  273. (make-variable-buffer-local 'sgml-always-quote-attributes)
  274.  
  275. (defcustom sgml-auto-insert-required-elements t
  276.   "*If non-nil, automatically insert required elements in the content
  277. of an inserted element."
  278.   :type 'boolean
  279.   :group 'psgml-insert)
  280.  
  281. (defcustom sgml-balanced-tag-edit t
  282.   "*If non-nil, always insert start-end tag pairs."
  283.   :type 'boolean
  284.   :group 'psgml-insert)
  285.  
  286. (defcustom sgml-omittag-transparent (not sgml-balanced-tag-edit) ;; wing change
  287.   "*If non-nil, will show legal tags inside elements with omittable start tags
  288. and legal tags beyond omittable end tags."
  289.   :type 'boolean
  290.   :group 'psgml)
  291.  
  292. (defcustom sgml-leave-point-after-insert nil
  293.   "*If non-nil, the point will remain after inserted tag(s).
  294. If nil, the point will be placed before the inserted tag(s)."
  295.   :type 'boolean
  296.   :group 'psgml-insert)
  297.  
  298. (defcustom sgml-warn-about-undefined-elements t
  299.   "*If non-nil, print a warning when a tag for an undefined element is found."
  300.   :type 'boolean
  301.   :group 'psgml)
  302.  
  303. (defcustom sgml-warn-about-undefined-entities t
  304.   "*If non-nil, print a warning when an undefined entity is found."
  305.   :type 'boolean
  306.   :group 'psgml)
  307.  
  308. (defcustom sgml-ignore-undefined-elements nil
  309.   "*If non-nil, recover from an undefined element by ignoring the tag.
  310. If nil, recover from an undefined element by assuming it can occur any
  311. where and has content model ANY."
  312.   :type 'boolean
  313.   :group 'psgml)
  314.  
  315. (defcustom sgml-recompile-out-of-date-cdtd 'ask
  316.   "*If non-nil, out of date compiled DTDs will be automatically recompiled.
  317. If the value is `ask', PSGML will ask before recompiling. A `nil'
  318. value will cause PSGML to silently load an out of date compiled DTD.
  319. A DTD that referes to undefined external entities is always out of
  320. date, thus in such case it can be useful to set this variable to
  321. `nil'."
  322.   :type 'symbol
  323.   :group 'psgml-dtd)
  324. (put 'sgml-recompile-out-of-date-cdtd 'sgml-type '(("No" . nil)
  325.                            ("Yes" . t)
  326.                            ("Ask" . ask)))
  327.  
  328. (defcustom sgml-trace-entity-lookup nil
  329.   "*If non-nil, log messages about catalog files used to look for
  330. external entities."
  331.   :type 'boolean
  332.   :group 'psgml-dtd) 
  333.  
  334. (defvar sgml-indent-step 2
  335.   "*How much to increment indent for every element level.
  336. If nil, no indentation.
  337. Setting this variable automatically makes it local to the current buffer.")
  338. (make-variable-buffer-local 'sgml-indent-step)
  339. (put 'sgml-indent-step 'sgml-type '(("None" . nil) 0 1 2 3 4 5 6 7 8))
  340.  
  341. (defvar sgml-indent-data nil
  342.   "*If non-nil, indent in data/mixed context also.
  343. Setting this variable automatically makes it local to the current buffer.")
  344. (make-variable-buffer-local 'sgml-indent-data)
  345.  
  346. ;;; Wing addition
  347. (defcustom sgml-inhibit-indent-tags nil
  348.   "*List of tags within which indentation is inhibited.
  349. The tags should be given as strings."
  350.   :type 'boolean
  351.   :group 'psgml)
  352.  
  353. (defvar sgml-data-directory (locate-data-directory "sgml")
  354.   "*Directory for pre-supplied data files (DTD's and such).
  355. Set this before loading psgml.")
  356.  
  357. (defcustom sgml-system-path nil
  358.   ;; wing addition
  359.   "*List of directories used to look for system identifiers.
  360. The directory listed in `sgml-data-directory' is always searched in
  361. addition to the directories listed here."
  362.   :type '(repeat directory)
  363.   :group 'psgml)
  364. (put 'sgml-system-path 'sgml-type 'list)
  365.  
  366. (defun sgml-parse-colon-path (cd-path)
  367.   "Explode a colon-separated list of paths into a string list."
  368.   (let (cd-list (cd-start 0) cd-colon)
  369.     (setq cd-path (concat cd-path ":"))
  370.     (while (setq cd-colon (string-match ":" cd-path cd-start))
  371.       (setq cd-list
  372.         (nconc cd-list
  373.            (list (if (= cd-start cd-colon)
  374.                  nil
  375.                (substitute-in-file-name
  376.                 (substring cd-path cd-start cd-colon))))))
  377.       (setq cd-start (+ cd-colon 1)))
  378.     cd-list))
  379.  
  380. (defcustom sgml-public-map (sgml-parse-colon-path
  381.                 (or (getenv "SGML_PATH")
  382.                 ;; Wing change
  383.                 (concat "%S:" (directory-file-name
  384.                            sgml-data-directory)
  385.                     "/%o/%c/%d")))
  386.   
  387.   "*Mapping from public identifiers to file names.
  388. This is a list of possible file names.  To find the file for a public
  389. identifier the elements of the list are used one at the time from the
  390. beginning.  If the element is a string a file name is constructed from
  391. the string by substitution of the whole public identifier for %P,
  392. owner for %O, public text class for %C, and public text description
  393. for %D.  The text class will be converted to lower case and the owner
  394. and description will be transliterated according to the variable
  395. sgml-public-transliterations.  If the file exists it will be the file
  396. used for the public identifier.  An element can also be a dotted pair
  397. (regexp . filename), the filename is a string treated as above, but
  398. only if the regular expression, regexp, matches the public
  399. identifier."
  400.   :type '(repeat file)
  401.   :group 'psgml-dtd)
  402. (put 'sgml-public-map 'sgml-type 'list)
  403.  
  404. (defcustom sgml-local-catalogs nil
  405. "*A list of SGML entity catalogs to be searched first when parsing the buffer.
  406. This is used in addtion to `sgml-catalog-files',  and `sgml-public-map'.
  407. This variable is automatically local to the buffer."
  408.   :type '(repeat file)
  409.   :group 'psgml-dtd)
  410. (make-variable-buffer-local 'sgml-local-catalogs)
  411. (put 'sgml-local-catalogs 'sgml-type 'list)
  412.  
  413. (defcustom sgml-catalog-files (sgml-parse-colon-path
  414.                 (or (getenv "SGML_CATALOG_FILES")
  415.                 ;; Wing addition
  416.                 (concat "CATALOG:"
  417.                                        (expand-file-name
  418.                                         "CATALOG"
  419.                                         sgml-data-directory))))
  420.   "*List of catalog entry files.
  421. The files are in the format defined in the SGML Open Draft Technical
  422. Resolution on Entity Management."
  423.   :type '(repeat file)
  424.   :group 'psgml-dtd)
  425. (put 'sgml-catalog-files 'sgml-type 'list)
  426.  
  427. ;;; Wing addition
  428. (defcustom sgml-ecat-files (list
  429.              "ECAT"
  430.              "~/sgml/ECAT"
  431.              (expand-file-name "ECAT" sgml-data-directory))
  432.   "*List of catalog files for PSGML."
  433.   :type '(repeat file)
  434.   :group 'psgml-dtd)
  435. (put 'sgml-ecat-files 'sgml-type 'list)
  436.  
  437. (defcustom sgml-local-ecat-files nil
  438.   "*List of local catalog files for PSGML.
  439. Automatically becomes buffer local if set."
  440.   :type '(repeat file)
  441.   :group 'psgml-dtd)
  442. (make-variable-buffer-local 'sgml-local-ecat-files)
  443. (put 'sgml-local-ecat-files 'sgml-type 'list)
  444.  
  445. (defvar sgml-public-transliterations '((? . ?_) (?/ . ?%))
  446.   "*Transliteration for characters that should be avoided in file names.
  447. This is a list of dotted pairs (FROM . TO); where FROM is the the
  448. character to be translated to TO.  This is used when parts of a public
  449. identifier are used to construct a file name.")
  450.  
  451. (defvar sgml-default-dtd-file nil
  452.   "*This is the default file name for saved DTD.
  453. This is set by sgml-mode from the buffer file name.
  454. Can be changed in the Local variables section of the file.")
  455. (put 'sgml-default-dtd-file 'sgml-type 'string)
  456. (put 'sgml-default-dtd-file 'sgml-desc "Default (saved) DTD File")
  457.  
  458. (defvar sgml-exposed-tags '()
  459.   "*The list of tag names that remain visible, despite \\[sgml-hide-tags].
  460. Each name is a lowercase string, and start-tags and end-tags must be
  461. listed individually.
  462.  
  463. `sgml-exposed-tags' is local to each buffer in which it has been set;
  464. use `setq-default' to set it to a value that is shared among buffers.")
  465. (make-variable-buffer-local 'sgml-exposed-tags)
  466. (put 'sgml-exposed-tags 'sgml-type 'list)
  467.  
  468.  
  469. (defvar sgml-custom-markup nil
  470.   "*Menu entries to be added to the Markup menu.
  471. The value should be a list of lists of two strings.  The first is a
  472. string is the menu line and the second string is the text inserted
  473. when the menu item is chosen.  The second string can contain a \\r
  474. where the cursor should be left.  Also if a selection is made
  475. according the same rules as for the Tags menu, the selection is
  476. replaced with the second string and \\r is replaced with the
  477. selection.
  478.  
  479. Example:
  480.  
  481.   ((\"Version1\" \"<![%Version1[\\r]]>\")
  482.    (\"New page\"  \"<?NewPage>\"))
  483. ")
  484.  
  485. (defcustom sgml-custom-dtd nil
  486.   "Menu entries to be added to the DTD menu.
  487. The value should be a list of entries to be added to the DTD menu.
  488. Every entry should be a list. The first element of the entry is a string
  489. used as the menu entry.  The second element is a string containing a
  490. doctype declaration (this can be nil if no doctype).  The rest of the
  491. list should be a list of variables and values.  For backward
  492. compatibility a singel string instead of a variable is assigned to
  493. sgml-default-dtd-file.  All variables are made buffer local and are also
  494. added to the buffers local variables list.
  495.  
  496. Example:
  497.    ((\"HTML\" nil
  498.      sgml-default-dtd-file \"~/sgml/html.ced\"
  499.      sgml-omittag nil sgml-shorttag nil)
  500.     (\"HTML+\" \"<!doctype htmlplus system 'htmlplus.dtd'>\"
  501.      \"~/sgml/htmlplus.ced\"
  502.      sgml-omittag t sgml-shorttag nil)
  503.     (\"DOCBOOK\" \"<!doctype docbook system 'docbook.dtd'>\"
  504.      \"~/sgml/docbook.ced\"
  505.      sgml-omittag nil sgml-shorttag t)))
  506. "
  507.   :type '(repeat (list (string :tag "Menu Entry")
  508.                (choice (const :tag "No doctype")
  509.                    (string :tag "Declaration"))
  510.                (repeat :inline t
  511.                    (list :inline t
  512.                      (symbol :tag "Variable")
  513.                      (sexp :tag "Value")))))
  514.   :group 'psgml-dtd)
  515.                    
  516.  
  517.  
  518. ;;; Faces used in edit attribute buffer:
  519. (put 'sgml-default 'face 'underline)    ; Face for #DEFAULT
  520. (put 'sgml-fixed 'face 'underline)    ; Face of #FIXED "..."
  521.  
  522.  
  523. ;;; sgmls is a free SGML parser available from
  524. ;;; ftp.uu.net:pub/text-processing/sgml
  525. ;;; Its error messages can be parsed by next-error.
  526. ;;; The -s option suppresses output.
  527.  
  528. (defcustom sgml-validate-command (concat "nsgmls -s -m "
  529.                      sgml-data-directory
  530.                      "/CATALOG %s %s")
  531.   "*The shell command to validate an SGML document.
  532.  
  533. This is a `format' control string that by default should contain two
  534. `%s' conversion specifications: the first will be replaced by the
  535. value of `sgml-declaration' \(or the empty string, if nil\); the
  536. second will be replaced by the current buffer's file name \(or the
  537. empty string, if nil\).
  538.  
  539. If `sgml-validate-files' is non-nil, the format string should contain
  540. one `%s' conversion specification for each element of its result.
  541.  
  542. If sgml-validate-command is a list, then every element should be a
  543. string.  The strings will be tried in order and %-sequences in the
  544. string will be replaced according to the list below, if the string contains
  545. %-sequences with no replacement value the next string will be tried.
  546.  
  547. %b means the visited file of the current buffer
  548. %s means the SGML declaration specified in the sgml-declaration variable
  549. %d means the file containing the DOCTYPE declaration, if not in the buffer 
  550. "
  551.   :type 'string
  552.   :group 'psgml)
  553.  
  554. (defvar sgml-validate-files nil
  555.   "If non-nil, a function of no arguments that returns a list of file names.
  556. These file names will serve as the arguments to the `sgml-validate-command'
  557. format control string instead of the defaults.")
  558.  
  559. (defvar sgml-validate-error-regexps
  560.   '((":\\(.+\\):\\([0-9]+\\):\\([0-9]+\\):[EX]: " 1 2 3)
  561.     ("\\(error\\|warning\\) at \\([^,]+\\), line \\([0-9]+\\)" 2 3)
  562.     ("\n[a-zA-Z]?:?[^0-9 \n\t:]+:[ \t]*\\([^ \n\t:]+\\):\
  563. \\([0-9]+\\):\\(\\([0-9]+\\)[: \t]\\)?" 1 2 4))
  564.   "Alist of regexps to recognize error messages from `sgml-validate'.
  565. See `compilation-error-regexp-alist'.")
  566.  
  567. (defcustom sgml-declaration nil
  568.   "*If non-nil, this is the name of the SGML declaration file."
  569.   :type 'hook
  570.   :group 'psgml-dtd)
  571. (put 'sgml-declaration 'sgml-type 'string)
  572.  
  573. (defcustom sgml-mode-hook nil
  574.   "A hook or list of hooks to be run when entering sgml-mode"
  575.   :type 'hook
  576.   :group 'psgml)
  577.  
  578. (defconst sgml-file-options
  579.   '(
  580.     sgml-omittag
  581.     sgml-shorttag
  582.     sgml-minimize-attributes
  583.     sgml-always-quote-attributes
  584.     sgml-indent-step
  585.     sgml-indent-data
  586.     sgml-doctype
  587.     sgml-parent-document
  588.     sgml-default-dtd-file
  589.     sgml-exposed-tags
  590.     sgml-local-catalogs
  591.     sgml-local-ecat-files
  592.     )
  593.   "Options for the current file, can be saved or set from menu."
  594.   )
  595.  
  596. (defconst sgml-user-options
  597.   '(
  598.     sgml-set-face
  599.     sgml-live-element-indicator
  600.     sgml-auto-activate-dtd
  601.     sgml-offer-save
  602.     sgml-tag-region-if-active
  603.     sgml-normalize-trims
  604.     sgml-auto-insert-required-elements
  605.     sgml-balanced-tag-edit
  606.     sgml-omittag-transparent
  607.     sgml-leave-point-after-insert
  608.     sgml-insert-missing-element-comment
  609.     sgml-insert-end-tag-on-new-line
  610.     sgml-warn-about-undefined-elements
  611.     sgml-warn-about-undefined-entities
  612.     sgml-ignore-undefined-elements
  613.     sgml-recompile-out-of-date-cdtd
  614.     sgml-default-doctype-name
  615.     sgml-declaration
  616.     sgml-validate-command
  617.     sgml-markup-faces
  618.     sgml-system-identifiers-are-preferred
  619.     sgml-trace-entity-lookup
  620.     sgml-system-path
  621.     sgml-public-map
  622.     sgml-catalog-files
  623.     sgml-ecat-files
  624.     )
  625.   "User options that can be saved or set from menu."
  626.   )
  627.  
  628. ;;; Internal variables
  629.  
  630. (defvar sgml-validate-command-history nil
  631.   "The minibuffer history list for `sgml-validate''s COMMAND argument.")
  632.  
  633. (defvar sgml-mode-map nil "Keymap for SGML mode")
  634.  
  635. (defvar sgml-active-dtd-indicator nil
  636.   "Displayed in the mode line")
  637.  
  638.  
  639. ;;;; User options handling
  640.  
  641. (defun sgml-variable-description (var)
  642.   (or (get var 'sgml-desc)
  643.       (let ((desc (symbol-name var)))
  644.     (if (string= "sgml-" (substring desc 0 5))
  645.         (setq desc (substring desc 5)))
  646.     (loop for c across-ref desc
  647.           do (if (eq c ?-) (setf c ? )))
  648.     (capitalize desc))))
  649.  
  650. (defun sgml-variable-type (var)
  651.   (or (get var 'sgml-type)
  652.       (if (memq (symbol-value var) '(t nil))
  653.       'toggle)))
  654.  
  655. (defun sgml-set-local-variable (var val)
  656.   "Set the value of variable VAR to VAL in buffer and local variables list."
  657.   (set (make-local-variable var) val)
  658.   (save-excursion
  659.     (let ((prefix "") 
  660.       (suffix "")
  661.       (case-fold-search t))
  662.       (goto-char (max (point-min) (- (point-max) 3000)))
  663.       (cond ((search-forward "Local Variables:" nil t)
  664.          (setq suffix (buffer-substring (point)
  665.                         (save-excursion (end-of-line 1)
  666.                                 (point))))
  667.          (setq prefix
  668.            (buffer-substring (save-excursion (beginning-of-line 1)
  669.                              (point))
  670.                      (match-beginning 0))))
  671.         (t
  672.          (goto-char (point-max))
  673.          (unless (bolp)
  674.            (insert ?\n))
  675.          (insert
  676.           "<!-- Keep this comment at the end of the file\n"
  677.           "Local variables:\n"
  678.           "mode: sgml\n"
  679.           "End:\n"
  680.           "-->\n")
  681.          (forward-line -3)))
  682.       (let* ((endpos (save-excursion
  683.                (search-forward (format "\n%send:" prefix))))
  684.          (varpos (search-forward (format "\n%s%s:" prefix var) endpos t)))
  685.     (cond (varpos
  686.            (delete-region (point)
  687.                   (save-excursion (end-of-line 1)
  688.                           (point)))
  689.            (insert (format "%S" val) suffix))
  690.           (t
  691.            (goto-char endpos)
  692.            (beginning-of-line 1)
  693.            (insert prefix (format "%s:%S" var val) suffix ?\n)))))))
  694.  
  695. (defun sgml-valid-option (var)
  696.   (let ((type (sgml-variable-type var))
  697.     (val (symbol-value var)))
  698.     (cond ((eq 'string type)
  699.        (stringp val))
  700.       ((eq 'list-or-string type)
  701.        (or (stringp val)
  702.            (consp val)))
  703.       (t
  704.        t))))
  705.  
  706. (defun sgml-save-options ()
  707.   "Save user options for sgml-mode that have buffer local values."
  708.   (interactive)
  709.   (loop for var in sgml-file-options do
  710.     (when (sgml-valid-option var)
  711.       (sgml-set-local-variable var (symbol-value var)))))
  712.  
  713.  
  714. ;;;; Run hook with args
  715.  
  716. (unless (fboundp 'run-hook-with-args)
  717.   (defun run-hook-with-args (hook &rest args)
  718.     "Run HOOK with the specified arguments ARGS.
  719. HOOK should be a symbol, a hook variable.  If HOOK has a non-nil
  720. value, that value may be a function or a list of functions to be
  721. called to run the hook.  If the value is a function, it is called with
  722. the given arguments and its return value is returned.  If it is a list
  723. of functions, those functions are called, in order,
  724. with the given arguments ARGS.
  725. It is best not to depend on the value return by `run-hook-with-args',
  726. as that may change."
  727.     (and (boundp hook)
  728.      (symbol-value hook)
  729.      (let ((value (symbol-value hook)))
  730.        (if (and (listp value) (not (eq (car value) 'lambda)))
  731.            (mapcar '(lambda (foo) (apply foo args))
  732.                value)
  733.          (apply value args))))))
  734.  
  735.  
  736.  
  737.  
  738. ;;;; SGML mode: template functions
  739.  
  740. (defun sgml-markup (entry text)
  741.   (cons entry
  742.     (` (lambda ()
  743.          (interactive)
  744.          (sgml-insert-markup (, text))))))
  745.  
  746. (defun sgml-insert-markup (text)
  747.   (let ((end (sgml-mouse-region))
  748.     before after
  749.     old-text)
  750.     (when end
  751.       (setq old-text (buffer-substring (point) end))
  752.       (delete-region (point) end))
  753.     (setq before (point))
  754.     (if (stringp text)
  755.     (insert text)
  756.       (eval text))
  757.     (setq after (point))
  758.     (goto-char before)
  759.     (when (search-forward "\r" after t)
  760.       (delete-char -1))
  761.     (when old-text (insert old-text))))
  762.  
  763. (defun sgml-mouse-region ()
  764.   (let (start end)
  765.     (cond
  766.      (sgml-running-xemacs
  767.       (cond
  768.        ((null (mark-marker)) nil)
  769.        (t (setq start (region-beginning)
  770.          end (region-end)))))
  771.      ((and transient-mark-mode
  772.        mark-active)
  773.       (setq start (region-beginning)
  774.         end (region-end)))
  775.      ((and mouse-secondary-overlay
  776.        (eq (current-buffer)
  777.            (overlay-buffer mouse-secondary-overlay)))
  778.       (setq start (overlay-start mouse-secondary-overlay)
  779.         end (overlay-end mouse-secondary-overlay))
  780.       (delete-overlay mouse-secondary-overlay)))
  781.     (when start
  782.       (goto-char start))
  783.     end))
  784.  
  785.  
  786. ;;;; SGML mode: indentation 
  787.  
  788. (defun sgml-indent-or-tab ()
  789.   "Indent line in proper way for current major mode."
  790.   (interactive)
  791.   (if (null sgml-indent-step)
  792.       (insert-tab)
  793.     (funcall indent-line-function)))
  794.  
  795. ;;;; Bug reporting
  796.  
  797. (eval-and-compile
  798.   (autoload 'reporter-submit-bug-report "reporter"))
  799.  
  800. (defun sgml-submit-bug-report ()
  801.   "Submit via mail a bug report on PSGML."
  802.   (interactive)
  803.   (and (y-or-n-p "Do you really want to submit a report on PSGML? ")
  804.        (reporter-submit-bug-report
  805.     psgml-maintainer-address
  806.     (concat "psgml.el " psgml-version)
  807.     (list 
  808.      'sgml-always-quote-attributes
  809.      'sgml-auto-activate-dtd
  810.      'sgml-auto-insert-required-elements
  811.      'sgml-balanced-tag-edit
  812.      'sgml-catalog-files 
  813.      'sgml-declaration
  814.      'sgml-doctype
  815.      'sgml-ecat-files
  816.      'sgml-indent-data
  817.      'sgml-indent-step
  818.      'sgml-leave-point-after-insert
  819.      'sgml-live-element-indicator
  820.      'sgml-local-catalogs 
  821.      'sgml-local-ecat-files
  822.      'sgml-markup-faces
  823.      'sgml-minimize-attributes
  824.      'sgml-normalize-trims
  825.      'sgml-omittag
  826.      'sgml-omittag-transparent
  827.      'sgml-parent-document
  828.      'sgml-public-map
  829.      'sgml-set-face
  830.      'sgml-shorttag
  831.      'sgml-tag-region-if-active
  832.      ))))
  833.  
  834.  
  835. ;;;; SGML mode: keys and menus
  836.  
  837. (if sgml-mode-map
  838.     ()
  839.   (setq sgml-mode-map (make-sparse-keymap)))
  840.  
  841. ;;; Key commands
  842.  
  843. (define-key sgml-mode-map [(tab)]    'sgml-indent-or-tab)
  844. ;;;(define-key sgml-mode-map [(?<)] 'sgml-insert-tag)
  845. (define-key sgml-mode-map [(?>)]     'sgml-close-angle)
  846. (define-key sgml-mode-map [(?/)]     'sgml-slash)
  847. (define-key sgml-mode-map [(control ?c) (?#)]    'sgml-make-character-reference)
  848. (define-key sgml-mode-map [(control ?c) (?-)]    'sgml-untag-element)
  849. (define-key sgml-mode-map [(control ?c) (?+)]    'sgml-insert-attribute)
  850. (define-key sgml-mode-map [(control ?c) (?/)]    'sgml-insert-end-tag)
  851. (define-key sgml-mode-map [(control ?c) (?<)]    'sgml-insert-tag)
  852. (define-key sgml-mode-map [(control ?c) (?=)]    'sgml-change-element-name)
  853. (define-key sgml-mode-map [(control ?c) (control ?a)] 'sgml-edit-attributes)
  854. (define-key sgml-mode-map [(control ?c) (control ?c)] 'sgml-show-context)
  855. (define-key sgml-mode-map [(control ?c) (control ?d)] 'sgml-next-data-field)
  856. (define-key sgml-mode-map [(control ?c) (control ?e)] 'sgml-insert-element)
  857. (define-key sgml-mode-map [(control ?c) (control ?k)] 'sgml-kill-markup)
  858. (define-key sgml-mode-map [(control ?c) (control ?l)] 'sgml-show-or-clear-log)
  859. (define-key sgml-mode-map [(control ?c) (control ?n)] 'sgml-up-element)
  860. (define-key sgml-mode-map [(control ?c) (control ?o)] 'sgml-next-trouble-spot)
  861. (define-key sgml-mode-map [(control ?c) (control ?p)] 'sgml-parse-prolog)
  862. (define-key sgml-mode-map [(control ?c) (control ?q)] 'sgml-fill-element)
  863. (define-key sgml-mode-map [(control ?c) (control ?r)] 'sgml-tag-region)
  864. (define-key sgml-mode-map [(control ?c) (control ?s)] 'sgml-unfold-line)
  865. (define-key sgml-mode-map [(control ?c) (control ?t)] 'sgml-list-valid-tags)
  866. (define-key sgml-mode-map [(control ?c) (control ?v)] 'sgml-validate)
  867. (define-key sgml-mode-map [(control ?c) (control ?w)] 'sgml-what-element)
  868. (define-key sgml-mode-map [(control ?c) (control ?z)] 'sgml-trim-and-leave-element)
  869. (define-key sgml-mode-map [(control ?c) (control ?f) (control ?e)] 'sgml-fold-element)
  870. (define-key sgml-mode-map [(control ?c) (control ?f) (control ?r)] 'sgml-fold-region)
  871. (define-key sgml-mode-map [(control ?c) (control ?f) (control ?s)] 'sgml-fold-subelement)
  872. (define-key sgml-mode-map [(control ?c) (control ?f) (control ?x)] 'sgml-expand-element)
  873. (define-key sgml-mode-map [(meta control ?O)] 'sgml-split-element)
  874. (define-key sgml-mode-map [(control ?c) (control ?u) (control ?e)] 'sgml-unfold-element)
  875. (define-key sgml-mode-map [(control ?c) (control ?u) (control ?a)] 'sgml-unfold-all)
  876. (define-key sgml-mode-map [(control ?c) (control ?u) (control ?l)] 'sgml-unfold-line)
  877. (define-key sgml-mode-map [(control ?c) (control ?u) (control ?d)] 'sgml-custom-dtd)
  878. (define-key sgml-mode-map [(control ?c) (control ?u) (control ?m)] 'sgml-custom-markup)
  879.  
  880. (define-key sgml-mode-map [(meta control ?a)]   'sgml-beginning-of-element)
  881. (define-key sgml-mode-map [(meta control ?e)]   'sgml-end-of-element)
  882. (define-key sgml-mode-map [(meta control ?f)]   'sgml-forward-element)
  883. (define-key sgml-mode-map [(meta control ?b)]   'sgml-backward-element)
  884. (define-key sgml-mode-map [(meta control ?d)]   'sgml-down-element)
  885. (define-key sgml-mode-map [(meta control ?u)]   'sgml-backward-up-element)
  886. (define-key sgml-mode-map [(meta control ?k)]   'sgml-kill-element)
  887. (define-key sgml-mode-map [(meta control ?@)]   'sgml-mark-element)
  888. (define-key sgml-mode-map [(meta control ?h)]   'sgml-mark-current-element)
  889. (define-key sgml-mode-map [(meta control ?t)]   'sgml-transpose-element)
  890. (define-key sgml-mode-map [(meta tab)]        'sgml-complete)
  891.  
  892. ;;;; Menu bar
  893.  
  894. (easy-menu-define
  895.  sgml-dtd-menu sgml-mode-map "DTD menu"
  896.  '("DTD"))
  897.  
  898. (defconst sgml-dtd-root-menu
  899.   '("DTD"
  900.     ["Parse DTD"  sgml-parse-prolog t]
  901.     ("Info"
  902.      ["General DTD info"    sgml-general-dtd-info           t]
  903.      ["Describe element type"    sgml-describe-element-type    t]
  904.      ["Describe entity"        sgml-describe-entity        t]
  905.      ["List elements"         sgml-list-elements         t]
  906.      ["List attributes"     sgml-list-attributes         t]
  907.      ["List terminals"         sgml-list-terminals         t]
  908.      ["List content elements"     sgml-list-content-elements     t]
  909.      ["List occur in elements"     sgml-list-occur-in-elements     t]
  910.      )
  911.     "--"
  912.     ["Load Parsed DTD"  sgml-load-dtd t]
  913.     ["Save Parsed DTD"  sgml-save-dtd t]
  914.     ))
  915.  
  916. (easy-menu-define
  917.  sgml-view-menu sgml-mode-map "View menu"
  918.  '("View"
  919.    ["Fold Element"    sgml-fold-element    t]
  920.    ["Fold Subelement"    sgml-fold-subelement    t]
  921.    ["Unfold Line"    sgml-unfold-line    t]
  922.    ["Unfold Element"    sgml-unfold-element    t]
  923.    ["Expand"        sgml-expand-element    t]
  924.    ["Fold Region"    sgml-fold-region    t]
  925.    ["Unfold All"    sgml-unfold-all        t]
  926.    ["Hide Tags"        sgml-hide-tags        t]
  927.    ["Hide Attributes"    sgml-hide-attributes    t]
  928.    ["Show All Tags"    sgml-show-tags        t]
  929.    )
  930.  )
  931.  
  932.  
  933. (defconst sgml-markup-root-menu
  934.   '("Markup"
  935.     ["Insert Element"    sgml-element-menu    t]
  936.     ["Insert Start-Tag" sgml-start-tag-menu    t]
  937.     ["Insert End-Tag"    sgml-end-tag-menu    t]
  938.     ["Tag Region"    sgml-tag-region-menu    t]
  939.     ["Insert Attribute" sgml-attrib-menu    t]
  940.     ["Insert Entity"    sgml-entities-menu    t]
  941.     ))
  942.  
  943. (easy-menu-define
  944.  sgml-markup-menu sgml-mode-map "Markup menu"
  945.  sgml-markup-root-menu)
  946.  
  947. (easy-menu-define
  948.  sgml-move-menu sgml-mode-map "Menu of move commands"
  949.  '("Move"
  950.    ["Next trouble spot" sgml-next-trouble-spot t]
  951.    ["Next data field"   sgml-next-data-field   t]
  952.    ["Forward element"    sgml-forward-element t]
  953.    ["Backward element"  sgml-backward-element t]
  954.    ["Up element"    sgml-up-element t]
  955.    ["Down element"    sgml-down-element t]
  956.    ["Backward up element" sgml-backward-up-element t]
  957.    ["Beginning of element" sgml-beginning-of-element t]
  958.    ["End of element"    sgml-end-of-element t]
  959.    ))
  960.  
  961. (easy-menu-define
  962.  sgml-modify-menu sgml-mode-map "Menu of modification commands"
  963.  '("Modify"
  964.    ["Normalize"            sgml-normalize    t]
  965.    ["Expand All Short References"    sgml-expand-all-shortrefs t]
  966.    ["Expand Entity Reference"    sgml-expand-entity-reference t]
  967.    ["Normalize Element"        sgml-normalize-element t]
  968.    ["Make Character Reference"    sgml-make-character-reference t]
  969.    ["Unmake Character Reference"    (sgml-make-character-reference t) t]
  970.    ["Fill Element"        sgml-fill-element t]
  971.    ["Change Element Name..."    sgml-change-element-name t]
  972.    ["Edit Attributes..."    sgml-edit-attributes t]
  973.    ["Kill Markup"        sgml-kill-markup t]
  974.    ["Kill Element"        sgml-kill-element t]
  975.    ["Untag Element"        sgml-untag-element t]
  976.    ["Trim and leave element"    sgml-trim-and-leave-element t]
  977.    ["Decode Character Entities"  sgml-charent-to-display-char t]
  978.    ["Encode Characters"        sgml-display-char-to-charent t]
  979.    )
  980.  )
  981.  
  982. (easy-menu-define
  983.  sgml-main-menu sgml-mode-map "Main menu"
  984.  '("SGML"
  985.    ["Reset Buffer"    normal-mode t]
  986.    ["End Element"    sgml-insert-end-tag t]
  987.    ["Show Context"    sgml-show-context t]
  988.    ["What Element"    sgml-what-element t]
  989.    ["List Valid Tags"    sgml-list-valid-tags t]
  990.    ["Show/Hide Warning Log"  sgml-show-or-clear-log t]
  991.    ["Validate"        sgml-validate t]
  992.    ["File Options >"    sgml-file-options-menu t]
  993.    ["User Options >"    sgml-user-options-menu t]
  994.    ["Save File Options"  sgml-save-options t]
  995.    ["Submit Bug Report"  sgml-submit-bug-report t]
  996.    )
  997.  )
  998.  
  999.  
  1000. (defun sgml-build-custom-menus ()
  1001.   "Build custom parts of Markup and DTD menus."
  1002.   (let ((button3 (lookup-key (current-local-map) [button3])))
  1003.     (easy-menu-define
  1004.      sgml-markup-menu sgml-mode-map "Markup menu"
  1005.      (append sgml-markup-root-menu
  1006.          (list "----")
  1007.          (loop for e in sgml-custom-markup collect
  1008.            (vector (first e)
  1009.                (` (sgml-insert-markup  (, (cadr e))))
  1010.                t))))
  1011.     (easy-menu-define
  1012.      sgml-dtd-menu sgml-mode-map "DTD menu"
  1013.      (append sgml-dtd-root-menu
  1014.          (list "----")
  1015.          (loop for e in sgml-custom-dtd collect
  1016.            (vector (first e)
  1017.                (` (sgml-doctype-insert (, (cadr e))
  1018.                            '(, (cddr e))))
  1019.                t))))    
  1020.     (unless (or (null button3)
  1021.         (numberp button3))
  1022.       (local-set-key [button3] button3))))
  1023.  
  1024.  
  1025. ;;;; Post command hook 
  1026.  
  1027. (defvar sgml-auto-activate-dtd-tried nil)
  1028. (make-variable-buffer-local 'sgml-auto-activate-dtd-tried)
  1029.  
  1030. (defvar sgml-buffer-parse-state nil
  1031.   "If the buffers DTD has been activated this contains the parser state.
  1032. The parser state has been created with `sgml-make-pstate' and contains
  1033. the information about the DTD and the parse tree.  This parse state is
  1034. actually only the state that persists between commands.")
  1035. (make-variable-buffer-local 'sgml-buffer-parse-state)
  1036.  
  1037. (eval-and-compile            ; Interface to psgml-parse
  1038.   (loop for fun in '(sgml-need-dtd sgml-update-display
  1039.                    sgml-fontify-buffer
  1040.                    sgml-subst-expand
  1041.                    sgml-declaration)
  1042.     do (autoload fun "psgml-parse")))
  1043.  
  1044.  
  1045. (defun sgml-command-post ()
  1046.   (when (eq major-mode 'sgml-mode)
  1047.     (when (and (null sgml-buffer-parse-state)
  1048.            sgml-auto-activate-dtd
  1049.            (null sgml-auto-activate-dtd-tried)
  1050.            (not (zerop (buffer-size)))
  1051.            (looking-at ".*<"))
  1052.       (setq sgml-auto-activate-dtd-tried t)
  1053.       (sgml-need-dtd)
  1054.       (sgml-fontify-buffer 0))
  1055.     (when sgml-buffer-parse-state
  1056.       (sgml-update-display))))
  1057.  
  1058.  
  1059. ;;;; SGML mode: major mode definition
  1060.  
  1061. ;;; This section is mostly from sgml-mode by James Clark.
  1062.  
  1063. ;;;###autoload
  1064. (defun sgml-mode ()
  1065.   "Major mode for editing SGML.\\<sgml-mode-map>
  1066. Makes > display the matching <.  Makes / display matching /.
  1067. Use \\[sgml-validate] to validate your document with an SGML parser.
  1068.  
  1069. You can find information with:
  1070. \\[sgml-show-context]  Show the nesting of elements at cursor position.
  1071. \\[sgml-list-valid-tags]  Show the tags valid at cursor position.
  1072.  
  1073. Insert tags with completion of contextually valid tags with \\[sgml-insert-tag].
  1074. End the current element with \\[sgml-insert-end-tag].  Insert an element (i.e.
  1075. both start and end tag) with \\[sgml-insert-element].  Or tag a region with 
  1076. \\[sgml-tag-region]. 
  1077.  
  1078. To tag a region with the mouse, use transient mark mode or secondary selection.
  1079.  
  1080. Structure editing:
  1081. \\[sgml-backward-element]  Moves backwards over the previous element.
  1082. \\[sgml-forward-element]  Moves forward over the next element.
  1083. \\[sgml-down-element]  Move forward and down one level in the element structure.
  1084. \\[sgml-backward-up-element]  Move backward out of this element level.
  1085. \\[sgml-beginning-of-element]  Move to after the start tag of the current element.
  1086. \\[sgml-end-of-element]  Move to before the end tag of the current element.
  1087. \\[sgml-kill-element]  Kill the element following the cursor.
  1088.  
  1089. Finding interesting positions
  1090. \\[sgml-next-data-field]  Move forward to next point where data is allowed.
  1091. \\[sgml-next-trouble-spot]  Move forward to next point where something is 
  1092.     amiss with the structure.
  1093.  
  1094. Folding and unfolding
  1095. \\[sgml-fold-element]  Fold the lines comprising the current element, leaving 
  1096.     the first line visible.
  1097. \\[sgml-fold-subelement]  Fold the elements in the content of the current element.
  1098.     Leaving the first line of every element visible.
  1099. \\[sgml-unfold-line]  Show hidden lines in current line.
  1100.  
  1101. User options:
  1102.  
  1103. sgml-omittag  Set this to reflect OMITTAG in the SGML declaration.
  1104. sgml-shortag  Set this to reflect SHORTTAG in the SGML declaration.
  1105. sgml-auto-insert-required-elements  If non-nil, automatically insert required 
  1106.     elements in the content of an inserted element.
  1107. sgml-balanced-tag-edit  If non-nil, always insert start-end tag pairs.
  1108. sgml-omittag-transparent  If non-nil, will show legal tags inside elements
  1109.     with omitable start tags and legal tags beyond omitable end tags.
  1110. sgml-leave-point-after-insert  If non-nil, the point will remain after 
  1111.     inserted tag(s).
  1112. sgml-warn-about-undefined-elements  If non-nil, print a warning when a tag 
  1113.     for a undefined element is found.
  1114. sgml-max-menu-size  Max number of entries in Tags and Entities menus before
  1115.      they are split into several panes.
  1116. sgml-always-quote-attributes  If non-nil, quote all attribute values 
  1117.     inserted after finishing edit attributes.
  1118. sgml-minimize-attributes  Determines minimization of attributes inserted by 
  1119.     edit-attributes.
  1120. sgml-normalize-trims  If non-nil, sgml-normalize will trim off white space 
  1121.     from end of element when adding end tag.
  1122. sgml-indent-step  How much to increament indent for every element level.
  1123. sgml-indent-data  If non-nil, indent in data/mixed context also.
  1124. sgml-set-face     If non-nil, psgml will set the face of parsed markup.
  1125. sgml-markup-faces The faces used when the above variable is non-nil.
  1126. sgml-system-path  List of directories used to look for system identifiers.
  1127. sgml-public-map  Mapping from public identifiers to file names.
  1128. sgml-offer-save  If non-nil, ask about saving modified buffers before
  1129.         \\[sgml-validate] is run.
  1130.  
  1131. All bindings:
  1132. \\{sgml-mode-map}
  1133. "
  1134.   (interactive)
  1135.   (kill-all-local-variables)
  1136.   (setq local-abbrev-table sgml-mode-abbrev-table)
  1137.   (use-local-map sgml-mode-map)
  1138.   (setq mode-name "SGML")
  1139.   (setq major-mode 'sgml-mode)
  1140.  
  1141.   ;; A start or end tag by itself on a line separates a paragraph.
  1142.   ;; This is desirable because SGML discards a newline that appears
  1143.   ;; immediately after a start tag or immediately before an end tag.
  1144.  
  1145.   (set (make-local-variable 'paragraph-separate)
  1146.     "^[ \t\n]*$\\|\
  1147. ^[ \t]*</?\\([A-Za-z]\\([-.A-Za-z0-9= \t\n]\\|\
  1148. \"[^\"]*\"\\|'[^']*'\\)*\\)?>$")
  1149.   (set (make-local-variable 'paragraph-start)
  1150.        paragraph-separate)
  1151.  
  1152.   (set-syntax-table text-mode-syntax-table)
  1153.   (make-local-variable 'comment-start)
  1154.   (setq comment-start "<!-- ")
  1155.   (make-local-variable 'comment-end)
  1156.   (setq comment-end " -->")
  1157.   (make-local-variable 'comment-indent-function)
  1158.   (setq comment-indent-function 'sgml-comment-indent)
  1159.   (make-local-variable 'comment-start-skip)
  1160.   ;; This will allow existing comments within declarations to be
  1161.   ;; recognized.  [Does not work well with auto-fill, Lst/940205]
  1162.   ;;(setq comment-start-skip "--[ \t]*")
  1163.   (setq comment-start-skip "<!--[ \t]*")
  1164.   ;; Added for psgml:
  1165.   (make-local-variable 'indent-line-function)
  1166.   (setq indent-line-function 'sgml-indent-line)
  1167.   (make-local-variable 'mode-line-format)
  1168.   ;; Modify mode-line-format with susbt (sugested by wing)
  1169.   (setq mode-line-format
  1170.     (subst '("" mode-name sgml-active-dtd-indicator) 'mode-name
  1171.            mode-line-format))
  1172.   (make-local-variable 'sgml-default-dtd-file)
  1173.   (when (setq sgml-default-dtd-file (sgml-default-dtd-file))
  1174.     (unless (file-exists-p sgml-default-dtd-file)
  1175.       (setq sgml-default-dtd-file nil)))
  1176.   (add-hook 'post-command-hook 'sgml-command-post 'append)
  1177.   (run-hooks 'text-mode-hook 'sgml-mode-hook)
  1178.   (sgml-build-custom-menus)
  1179.   (easy-menu-add sgml-main-menu)
  1180.   (easy-menu-add sgml-modify-menu)
  1181.   (easy-menu-add sgml-move-menu)
  1182.   (easy-menu-add sgml-markup-menu)
  1183.   (easy-menu-add sgml-view-menu)
  1184.   (easy-menu-add sgml-dtd-menu))
  1185.  
  1186. (defun sgml-default-dtd-file ()
  1187.   (and (buffer-file-name)
  1188.        (let ((base (file-name-nondirectory (buffer-file-name))))
  1189.      (concat
  1190.       (cond ((string-match "\\.[^.]+$" base)
  1191.          (substring base 0 (match-beginning 0)))
  1192.         (t
  1193.          base))
  1194.       ".ced"))))
  1195.  
  1196. (defun sgml-comment-indent ()
  1197.   (if (and (looking-at "--")
  1198.        (not (and (eq (char-after (1- (point))) ?!)
  1199.              (eq (char-after (- (point) 2)) ?<))))
  1200.       (progn
  1201.     (skip-chars-backward " \t")
  1202.     (max comment-column (1+ (current-column))))
  1203.     0))
  1204.  
  1205. (defconst sgml-start-tag-regex
  1206.   "<[A-Za-z]\\([-.A-Za-z0-9= \n\t]\\|\"[^\"]*\"\\|'[^']*'\\)*"
  1207.   "Regular expression that matches a non-empty start tag.
  1208. Any terminating > or / is not matched.")
  1209.  
  1210. (defvar sgml-mode-markup-syntax-table nil
  1211.   "Syntax table used for scanning SGML markup.")
  1212.  
  1213. (if sgml-mode-markup-syntax-table
  1214.     ()
  1215.   (setq sgml-mode-markup-syntax-table (make-syntax-table))
  1216.   (modify-syntax-entry ?< "(>" sgml-mode-markup-syntax-table)
  1217.   (modify-syntax-entry ?> ")<" sgml-mode-markup-syntax-table)
  1218.   (modify-syntax-entry ?- "_ 1234" sgml-mode-markup-syntax-table)
  1219.   (modify-syntax-entry ?\' "\"" sgml-mode-markup-syntax-table))
  1220.  
  1221. (defconst sgml-angle-distance 4000
  1222.   "*If non-nil, is the maximum distance to search for matching <.")
  1223.  
  1224. (defun sgml-close-angle (arg)
  1225.   "Insert > and display matching <."
  1226.   (interactive "p")
  1227.   (insert-char ?> arg)
  1228.   (if (> arg 0)
  1229.       (let ((oldpos (point))
  1230.         (blinkpos))
  1231.     (save-excursion
  1232.       (save-restriction
  1233.         (if sgml-angle-distance
  1234.         (narrow-to-region (max (point-min)
  1235.                        (- (point) sgml-angle-distance))
  1236.                   oldpos))
  1237.         ;; See if it's the end of a marked section.
  1238.         (and (> (- (point) (point-min)) 3)
  1239.          (eq (char-after (- (point) 2)) ?\])
  1240.          (eq (char-after (- (point) 3)) ?\])
  1241.          (re-search-backward "<!\\[\\(-?[A-Za-z0-9. \t\n&;]\\|\
  1242. --\\([^-]\\|-[^-]\\)*--\\)*\\["
  1243.                      (point-min)
  1244.                      t)
  1245.          (let ((msspos (point)))
  1246.            (if (and (search-forward "]]>" oldpos t)
  1247.                 (eq (point) oldpos))
  1248.                (setq blinkpos msspos))))
  1249.         ;; This handles cases where the > ends one of the following:
  1250.         ;; markup declaration starting with <! (possibly including a
  1251.         ;; declaration subset); start tag; end tag; SGML declaration.
  1252.         (if blinkpos
  1253.         ()
  1254.           (goto-char oldpos)
  1255.           (condition-case ()
  1256.           (let ((oldtable (syntax-table))
  1257.             (parse-sexp-ignore-comments t))
  1258.             (unwind-protect
  1259.             (progn
  1260.               (set-syntax-table sgml-mode-markup-syntax-table)
  1261.               (setq blinkpos (scan-sexps oldpos -1)))
  1262.               (set-syntax-table oldtable)))
  1263.         (error nil))
  1264.           (and blinkpos
  1265.            (goto-char blinkpos)
  1266.            (or
  1267.             ;; Check that it's a valid delimiter in context.
  1268.             (not (looking-at
  1269.               "<\\(\\?\\|/?[A-Za-z>]\\|!\\([[A-Za-z]\\|--\\)\\)"))
  1270.             ;; Check that it's not a net-enabling start tag
  1271.             ;; nor an unclosed start-tag.
  1272.             (looking-at (concat sgml-start-tag-regex "[/<]"))
  1273.             ;; Nor an unclosed end-tag.
  1274.             (looking-at "</[A-Za-z][-.A-Za-z0-9]*[ \t]*<"))
  1275.            (setq blinkpos nil)))
  1276.         (if blinkpos
  1277.         ()
  1278.           ;; See if it's the end of a processing instruction.
  1279.           (goto-char oldpos)
  1280.           (if (search-backward "<?" (point-min) t)
  1281.           (let ((pipos (point)))
  1282.             (if (and (search-forward ">" oldpos t)
  1283.                  (eq (point) oldpos))
  1284.             (setq blinkpos pipos))))))
  1285.       (if blinkpos
  1286.           (progn
  1287.         (goto-char blinkpos)
  1288.         (if (pos-visible-in-window-p)
  1289.             (sit-for 1)
  1290.           (message "Matches %s"
  1291.                (buffer-substring blinkpos
  1292.                          (progn (end-of-line)
  1293.                             (point)))))))))))
  1294.  
  1295. ;;; I doubt that null end tags are used much for large elements,
  1296. ;;; so use a small distance here.
  1297. (defconst sgml-slash-distance 1000
  1298.   "*If non-nil, is the maximum distance to search for matching /.")
  1299.  
  1300. (defun sgml-slash (arg)
  1301.   "Insert / and display any previous matching /.
  1302. Two /s are treated as matching if the first / ends a net-enabling
  1303. start tag, and the second / is the corresponding null end tag."
  1304.   (interactive "p")
  1305.   (insert-char ?/ arg)
  1306.   (if (> arg 0)
  1307.       (let ((oldpos (point))
  1308.         (blinkpos)
  1309.         (level 0))
  1310.     (save-excursion
  1311.       (save-restriction
  1312.         (if sgml-slash-distance
  1313.         (narrow-to-region (max (point-min)
  1314.                        (- (point) sgml-slash-distance))
  1315.                   oldpos))
  1316.         (if (and (re-search-backward sgml-start-tag-regex (point-min) t)
  1317.              (eq (match-end 0) (1- oldpos)))
  1318.         ()
  1319.           (goto-char (1- oldpos))
  1320.           (while (and (not blinkpos)
  1321.               (search-backward "/" (point-min) t))
  1322.         (let ((tagend (save-excursion
  1323.                 (if (re-search-backward sgml-start-tag-regex
  1324.                             (point-min) t)
  1325.                     (match-end 0)
  1326.                   nil))))
  1327.           (if (eq tagend (point))
  1328.               (if (eq level 0)
  1329.               (setq blinkpos (point))
  1330.             (setq level (1- level)))
  1331.             (setq level (1+ level)))))))
  1332.       (if blinkpos
  1333.           (progn
  1334.         (goto-char blinkpos)
  1335.         (if (pos-visible-in-window-p)
  1336.             (sit-for 1)
  1337.           (message "Matches %s"
  1338.                (buffer-substring (progn
  1339.                            (beginning-of-line)
  1340.                            (point))
  1341.                          (1+ blinkpos))))))))))
  1342.  
  1343. (eval-and-compile
  1344.   (autoload 'compile-internal "compile" ""))
  1345.  
  1346. (defun sgml-default-validate-command ()
  1347.   (cond
  1348.    ((consp sgml-validate-command)
  1349.     (let ((validate-subst
  1350.        (list
  1351.         (cons ?b (and (buffer-file-name)
  1352.               (file-name-nondirectory (buffer-file-name))))
  1353.         (cons ?s (sgml-declaration))
  1354.         (cons ?v sgml-declaration)
  1355.         (cons ?d sgml-doctype))))
  1356.       (loop for template in sgml-validate-command
  1357.         thereis
  1358.         (sgml-subst-expand template validate-subst))))
  1359.    (t
  1360.     (apply 'format sgml-validate-command
  1361.        (if sgml-validate-files
  1362.            (funcall sgml-validate-files)
  1363.          (list (or sgml-declaration "")
  1364.            (let ((name (buffer-file-name)))
  1365.              (if name
  1366.              (file-name-nondirectory name)
  1367.                ""))))))))
  1368.  
  1369. (defun sgml-validate (command)
  1370.   "Validate an SGML document.
  1371. Runs COMMAND, a shell command, in a separate process asynchronously
  1372. with output going to the buffer *compilation*.
  1373. You can then use the command \\[next-error] to find the next error message
  1374. and move to the line in the SGML document that caused it."
  1375.   (interactive
  1376.    (list (read-from-minibuffer "Validate command: "
  1377.                    (sgml-default-validate-command)
  1378.                    nil nil 'sgml-validate-command-history)))
  1379.   (if sgml-offer-save
  1380.       (save-some-buffers nil nil))
  1381.   (compile-internal command "No more errors" "SGML validation"
  1382.             nil
  1383.             sgml-validate-error-regexps))
  1384.  
  1385.  
  1386.  
  1387. ;;;; Autoloads and hooks
  1388.  
  1389. (autoload 'sgml-doctype-insert "psgml-edit"
  1390.       nil
  1391.       nil nil)
  1392. (autoload 'sgml-indent-line "psgml-edit" nil)
  1393. (autoload 'sgml-element-endable-p "psgml-edit" nil)
  1394.  
  1395. ;;; Generated by sgml-build-autoloads
  1396.  
  1397. (autoload 'sgml-load-dtd "psgml-parse" "Load a saved DTD from FILE." t)
  1398. (autoload 'sgml-show-or-clear-log "psgml-parse" "Show the *SGML LOG* buffer if it is not showing, or clear and
  1399. remove it if it is showing." t)
  1400. (autoload 'sgml-parse-prolog "psgml-parse" "Parse the document prolog to learn the DTD." t)
  1401. (autoload 'sgml-beginning-of-element "psgml-edit" "Move to after the start-tag of the current element.
  1402. If the start-tag is implied, move to the start of the element." t)
  1403. (autoload 'sgml-end-of-element "psgml-edit" "Move to before the end-tag of the current element." t)
  1404. (autoload 'sgml-backward-up-element "psgml-edit" "Move backward out of this element level.
  1405. That is move to before the start-tag or where a start-tag is implied." t)
  1406. (autoload 'sgml-up-element "psgml-edit" "Move forward out of this element level.
  1407. That is move to after the end-tag or where an end-tag is implied." t)
  1408. (autoload 'sgml-forward-element "psgml-edit" "Move forward over next element." t)
  1409. (autoload 'sgml-backward-element "psgml-edit" "Move backward over previous element at this level.
  1410. With implied tags this is ambigous." t)
  1411. (autoload 'sgml-down-element "psgml-edit" "Move forward and down one level in the element structure." t)
  1412. (autoload 'sgml-kill-element "psgml-edit" "Kill the element following the cursor." t)
  1413. (autoload 'sgml-transpose-element "psgml-edit" "Interchange element before point with element after point, leave point after." t)
  1414. (autoload 'sgml-mark-element "psgml-edit" "Set mark after next element." t)
  1415. (autoload 'sgml-mark-current-element "psgml-edit" "Set mark at end of current element, and leave point before current element." t)
  1416. (autoload 'sgml-change-element-name "psgml-edit" "Replace the name of the current element with a new name.
  1417. Eventual attributes of the current element will be translated if 
  1418. possible." t)
  1419. (autoload 'sgml-untag-element "psgml-edit" "Remove tags from current element." t)
  1420. (autoload 'sgml-kill-markup "psgml-edit" "Kill next tag, markup declaration or process instruction." t)
  1421. (autoload 'sgml-fold-region "psgml-edit" "Hide (or if prefixarg unhide) region.
  1422. If called from a program first two arguments are start and end of
  1423. region. And optional third argument true unhides." t)
  1424. (autoload 'sgml-fold-element "psgml-edit" "Fold the lines comprising the current element, leaving the first line visible.
  1425. This uses the selective display feature." t)
  1426. (autoload 'sgml-fold-subelement "psgml-edit" "Fold all elements current elements content, leaving the first lines visible.
  1427. This uses the selective display feature." t)
  1428. (autoload 'sgml-unfold-line "psgml-edit" "Show hidden lines in current line." t)
  1429. (autoload 'sgml-unfold-element "psgml-edit" "Show all hidden lines in current element." t)
  1430. (autoload 'sgml-expand-element "psgml-edit" "As sgml-fold-subelement, but unfold first." t)
  1431. (autoload 'sgml-unfold-all "psgml-edit" "Show all hidden lines in buffer." t)
  1432. (autoload 'sgml-next-data-field "psgml-edit" "Move forward to next point where data is allowed." t)
  1433. (autoload 'sgml-next-trouble-spot "psgml-edit" "Move forward to next point where something is amiss with the structure." t)
  1434. (autoload 'sgml-list-valid-tags "psgml-edit" "Display a list of the contextually valid tags." t)
  1435. (autoload 'sgml-show-context "psgml-edit" "Display where the cursor is in the element hierarchy." t)
  1436. (autoload 'sgml-what-element "psgml-edit" "Display what element is under the cursor." t)
  1437. (autoload 'sgml-insert-tag "psgml-edit" "Insert a tag, reading tag name in minibuffer with completion.
  1438. If the variable sgml-balanced-tag-edit is t, also inserts the
  1439. corresponding end tag. If sgml-leave-point-after-insert is t, the point
  1440. is left after the inserted tag(s), unless the element has som required
  1441. content.  If sgml-leave-point-after-insert is nil the point is left
  1442. after the first tag inserted." t)
  1443. (autoload 'sgml-insert-element "psgml-edit" "Reads element name from minibuffer and inserts start and end tags." t)
  1444. (autoload 'sgml-tag-region "psgml-edit" "Reads element name from minibuffer and inserts start and end tags." t)
  1445. (autoload 'sgml-insert-end-tag "psgml-edit" "Insert end-tag for the current open element." t)
  1446. (autoload 'sgml-insert-attribute "psgml-edit" "Read attribute name and value from minibuffer and insert attribute spec." t)
  1447. (autoload 'sgml-split-element "psgml-edit" "Split the current element at point.
  1448. If repeated, the containing element will be split before the beginning
  1449. of then current element." t)
  1450. (autoload 'sgml-custom-dtd "psgml-edit" "Insert a DTD declaration from the sgml-custom-dtd alist." t)
  1451. (autoload 'sgml-custom-markup "psgml-edit" "Insert markup from the sgml-custom-markup alist." t)
  1452. (autoload 'sgml-tags-menu "psgml-edit" "Pop up a menu with valid tags and insert the choosen tag.
  1453. If the variable sgml-balanced-tag-edit is t, also inserts the
  1454. corresponding end tag. If sgml-leave-point-after-insert is t, the point
  1455. is left after the inserted tag(s), unless the element has som required
  1456. content.  If sgml-leave-point-after-insert is nil the point is left
  1457. after the first tag inserted." t)
  1458. (autoload 'sgml-element-menu "psgml-edit" "Pop up a menu with valid elements and insert choice.
  1459. If sgml-leave-point-after-insert is nil the point is left after the first 
  1460. tag inserted." t)
  1461. (autoload 'sgml-start-tag-menu "psgml-edit" "Pop up a menu with valid start-tags and insert choice." t)
  1462. (autoload 'sgml-end-tag-menu "psgml-edit" "Pop up a menu with valid end-tags and insert choice." t)
  1463. (autoload 'sgml-tag-region-menu "psgml-edit" "Pop up a menu with valid elements and tag current region with the choice." t)
  1464. (autoload 'sgml-entities-menu "psgml-edit" nil t)
  1465. (autoload 'sgml-attrib-menu "psgml-edit" "Pop up a menu of the attributes of the current element
  1466. \(or the element whith start-tag before point)." t)
  1467. (autoload 'sgml-fill-element "psgml-edit" "Fill bigest enclosing element with mixed content.
  1468. If current element has pure element content, recursively fill the
  1469. subelements." t)
  1470. (autoload 'sgml-edit-attributes "psgml-edit" "Edit attributes of current element.
  1471. Editing is done in a separate window." t)
  1472. (autoload 'sgml-edit-attrib-finish "psgml-edit" "Finish editing and insert attribute values in original buffer." t)
  1473. (autoload 'sgml-edit-attrib-default "psgml-edit" "Set current attribute value to default." t)
  1474. (autoload 'sgml-edit-attrib-clear "psgml-edit" "Kill the value of current attribute." t)
  1475. (autoload 'sgml-edit-attrib-field-start "psgml-edit" "Go to the start of the attribute value field." t)
  1476. (autoload 'sgml-edit-attrib-field-end "psgml-edit" "Go to the end of the attribute value field." t)
  1477. (autoload 'sgml-edit-attrib-next "psgml-edit" "Move to next attribute value." t)
  1478. (autoload 'sgml-hide-tags "psgml-edit" "Hide all tags in buffer." t)
  1479. (autoload 'sgml-show-tags "psgml-edit" "Show hidden tags in buffer." t)
  1480. (autoload 'sgml-hide-attributes "psgml-edit" "Hide all attribute specifications in the buffer." t)
  1481. (autoload 'sgml-show-attributes "psgml-edit" "Show all attribute specifications in the buffer." t)
  1482. (autoload 'sgml-expand-all-shortrefs "psgml-edit" "Expand all short references in the buffer.
  1483. Short references to text entities are expanded to the replacement text
  1484. of the entity other short references are expanded into general entity
  1485. references.  If argument, TO-ENTITY, is non-nil, or if called
  1486. interactive with numeric prefix argument, all short references are
  1487. replaced by generaly entity references." t)
  1488. (autoload 'sgml-normalize "psgml-edit" "Normalize buffer by filling in omitted tags and expanding empty tags.
  1489. Argument TO-ENTITY controls how short references are expanded as with
  1490. `sgml-expand-all-shortrefs'.  An optional argument ELEMENT can be the
  1491. element to normalize insted of the whole buffer, if used no short
  1492. references will be expanded." t)
  1493. (autoload 'sgml-normalize-element "psgml-edit" nil t)
  1494. (autoload 'sgml-make-character-reference "psgml-edit" "Convert character after point into a character reference.
  1495. If called with a numeric argument, convert a character reference back
  1496. to a normal character.  If called from a program, set optional
  1497. argument INVERT to non-nil." t)
  1498. (autoload 'sgml-expand-entity-reference "psgml-edit" "Insert the text of the entity referenced at point." t)
  1499. (autoload 'sgml-complete "psgml-edit" "Complete the word/tag/entity before point.
  1500. If it is a tag (starts with < or </) complete with valid tags.
  1501. If it is an entity (starts with &) complete with declared entities.
  1502. If it is a markup declaration (starts with <!) complete with markup 
  1503. declaration names.
  1504. If it is something else complete with ispell-complete-word." t)
  1505. (autoload 'sgml-file-options-menu "psgml-edit" nil t)
  1506. (autoload 'sgml-user-options-menu "psgml-edit" nil t)
  1507. (autoload 'sgml-save-dtd "psgml-dtd" "Save the parsed dtd on FILE." t)
  1508. (autoload 'sgml-list-elements "psgml-info" "List the elements and their attributes in the current DTD." t)
  1509. (autoload 'sgml-list-attributes "psgml-info" "List the attributes and in which elements they occur." t)
  1510. (autoload 'sgml-list-terminals "psgml-info" "List the elements that can have data in their content." t)
  1511. (autoload 'sgml-list-content-elements "psgml-info" "List all element types and the element types that can occur in its content." t)
  1512. (autoload 'sgml-list-occur-in-elements "psgml-info" "List all element types and where it can occur." t)
  1513. (autoload 'sgml-describe-entity "psgml-info" "Describe the properties of an entity as declared in the current DTD." t)
  1514. (autoload 'sgml-describe-element-type "psgml-info" "Describe the properties of an element type as declared in the current DTD." t)
  1515. (autoload 'sgml-general-dtd-info "psgml-info" "Display information about the current DTD." t)
  1516. (autoload 'sgml-charent-to-display-char "psgml-charent" "Replace character entities with their display character equivalents" t)
  1517. (autoload 'sgml-display-char-to-charent "psgml-charent" "Replace displayable characters with their character entity equivalents" t)
  1518.  
  1519.  
  1520. ;;;; Last provisions
  1521. (provide 'psgml)
  1522. (provide 'sgml-mode)
  1523.  
  1524. (cond
  1525.  (sgml-running-xemacs
  1526.   (require 'psgml-xemacs))
  1527.  (t
  1528.   (require 'psgml-other)))
  1529.  
  1530. ;;; psgml.el ends here
  1531.